<script setup lang="ts">
import SvgIcon from "@/components/common/SvgIcon.vue";
defineProps({
  icon: {
    type: String,
    default: '标签'
  },
  text: {
    type: String,
    default: '标签'
  },
  color: {
    type: String,
    default: '#666666'
  },
  disabledIcon: {
    type: Boolean,
    default: false
  },
  transparent: {
    type: Boolean,
    default: false
  },
  fontSize: {
    type: String,
    default: '14px'
  }
})
</script>

<template>
  <div :class="{'tag-not-transparent': !transparent,'tag': true}" :style="{
    color: color,
    background: !transparent ? color : 'transparent',
    padding: !transparent ? '0 8px' : '0',
    'font-size':fontSize
  }">
    <SvgIcon v-if="!disabledIcon" class-name="tag-icon" :icon-class="icon"/>
    <p class="tag-text">{{ text }}</p>
  </div>
</template>

<style scoped lang="less">
.tag{
  height: 22px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  position: relative;
  z-index: 1;
  .tag-icon{
    color: inherit;
    width: 14px;
    height: 14px;
    margin-right: 4px;
  }
  .tag-text{
    color: inherit;
    line-height: 22px;
    text-align: center;
  }
  &:hover{
    cursor: pointer;
  }
}
.tag-not-transparent{
  &::after{
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.87); // 用于遮罩让背景颜色减淡
    border-radius: 4px;
    z-index: -1; // 用于放在背景颜色下
  }
}
</style>
